import * as api from './api'

export default {
  // 获取用户列表
  getUserList: (current, size, params) => {
    return api.get(`/manage/user/${current}/${size}`, params)
  },
  // 获取用户详情
  getUserDetail: (id) => {
    return api.get(`/manage/user/getDetail/${id}`)
  },
  // 获取用户统计
  getUserTotal: () => {
    return api.get('/manage/user/user-statistics')
  },
  // 获取用户数量
  getUserNum: () => {
    return api.get('/manage/user/count')
  },
  // 获取用户下拉列表
  getUserBox: (params) => {
    return api.get('/manage/user/box', params)
  },
  // 冻结|解冻用户
  modifyUserState: (params) => {
    const headers = {
      'lang-key': Number(params.status) === 2 ? 'beenFrozen' : 'unfreeze'
    }
    return api.put('/manage/user/freeze', params, headers)
  },
  // 修改用户身份
  modifyUserIdentity: (params) => {
    const headers = {
      'lang-key': 'modifyIdentity'
    }
    return api.put('/manage/user/identity', params, headers)
  },
  // 修改免费账户
  modifyUserFreeAccount: (params) => {
    const headers = {
      'lang-key': 'freeRent'
    }
    return api.put('/manage/user/free', params, headers)
  },
  // 解除绑定第三方账号信息
  unbindThirdAccount: (params) => {
    return api.put('/manage/user/unbind-account', params)
  },

  // 获取反馈列表
  getFeedbackList: (current, size, params) => {
    return api.get(`/manage/feedback/${current}/${size}`, params)
  },

  // 获取消息推送列表
  getMessageList: (current, size, params) => {
    return api.get(`/manage/message/${current}/${size}`, params)
  },
  // 获取消息推送详情
  getMessageDetail: (id) => {
    return api.get(`/manage/message/${id}`)
  },
  // 创建|编辑消息
  createModifyMessage: (params) => {
    const url = '/manage/message'
    const headers = {}
    if (params && params.id) {
      headers['lang-key'] = 'edit'
      return api.put(url, params, headers)
    } else {
      headers['lang-key'] = 'found'
      return api.post(url, params, headers)
    }
  },
  // 消息推送-取消发送
  messageCancel: (id) => {
    return api.put(`/manage/message/cancel/${id}`)
  },
  // 消息推送-继续发送
  messageResume: (id, pushTime) => {
    return api.put(`/manage/message/keep-on/${id}/${pushTime}`)
  },

  // 修改反馈状态
  modifyFeedbackState: (params) => {
    return api.put('/manage/feedback/state', params)
  }
}
